package cloud.agileframework.common.util.serializer;

import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.writer.ObjectWriter;

import java.lang.reflect.Type;

public class BooleanToNumberWriter implements ObjectWriter<Boolean> {

    @Override
    public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
        if (object instanceof Boolean) {
            jsonWriter.writeString(Boolean.TRUE.equals(object) ? "1" : "0");
        }
    }
}
